package component.dispatcher;

import analyser.node.v1.MibObjectTypeV1Analyser;
import model.MibModule;
import util.common.MibKeys;

import java.util.Collection;
import java.util.List;
import java.util.Map;

public class NodeAnalyseDispatcherV1 extends NodeAnalyseDispatcher {
    private static final String RFC1212 = "RFC-1212";
    private static final String RFC1212_MIB = "RFC1212-MIB";

    public NodeAnalyseDispatcherV1(MibModule module) {
        super(module);
    }

    public NodeAnalyseDispatcherV1(MibModule module, NodeAnalyseDispatcher next) {
        super(module, next);
    }

    @Override
    protected void despatch() {
        Map<String, List<String>> importsMap = this.module.ImportsModuleNodesMap;
        Collection<String> collection;
        if (importsMap == null)
            return;

        if (importsMap.containsKey(RFC1212) || importsMap.containsKey(RFC1212_MIB)){
            collection = importsMap.getOrDefault(RFC1212, importsMap.get(RFC1212_MIB));
            for(String name : collection){
                if (MibKeys.OBJECT_TYPE.equals(name)){
                    typeAnalyserMap.put(MibKeys.OBJECT_TYPE, MibObjectTypeV1Analyser.class);
                }
            }
        }
    }
}
